#include "ChannelRight.h"
#include "Configuration.h"

ChannelRight::ChannelRight(void)
{
	//get right par defaut
}

ChannelRight::ChannelRight(unsigned int id, const std::vector<bool>& right)
: _id(id), _right(right)
{
}

ChannelRight::~ChannelRight(void)
{
}

const unsigned int	ChannelRight::GetId(void) const
{
	return this->_id;
}

void	ChannelRight::SetChannelRight(const bool canCreate, const bool canDelete, const bool canEdit, const bool canEditUser, const bool canTalk, const bool canWrite, const bool canKick, const bool canBan)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRight(this->_id, canCreate, canDelete, canEdit, canEditUser, canTalk, canWrite, canKick, canBan);
	this->_right[0] = canCreate;
	this->_right[1] = canDelete;
	this->_right[2] = canEdit;
	this->_right[3] = canEditUser;
	this->_right[4] = canTalk;
	this->_right[5] = canWrite;
	this->_right[6] = canKick;
	this->_right[7] = canBan;
}

const bool	ChannelRight::GetCanCreateChannelChild(void) const
{
	return this->_right[0];
}

void	ChannelRight::SetCanCreateChannelChild(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanCreateChild(this->_id, value);
	this->_right[0] = value;
}

const bool	ChannelRight::GetCanDeleteChannelChild(void) const
{
	return this->_right[1];
}

void	ChannelRight::SetCanDeleteChannelChild(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanDeleteChild (this->_id, value);
	this->_right[1] = value;
}

const bool	ChannelRight::GetCanEditChannel(void) const
{
	return this->_right[2];
}

void	ChannelRight::SetCanEditChannel(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanEdit(this->_id, value);
	this->_right[2] = value;
}

const bool	ChannelRight::GetCanEditUserRight(void) const
{
	return this->_right[3];
}

void	ChannelRight::SetCanEditUserRight(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanEditUserRight(this->_id, value);
	this->_right[3] = value;
}

const bool	ChannelRight::GetCanTalkChannel(void) const
{
	return this->_right[4];
}

void	ChannelRight::SetCanTalkChannel(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanTalk(this->_id, value);
	this->_right[4] = value;
}

const bool	ChannelRight::GetCanWriteChannel(void) const
{
	return this->_right[5];
}

void	ChannelRight::SetCanWriteChannel(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanWrite(this->_id, value);
	this->_right[5] = value;
}

const bool	ChannelRight::GetCanKickUser(void) const
{
	return this->_right[6];
}

void	ChannelRight::SetCanKickUser(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanKick(this->_id, value);
	this->_right[6] = value;
}

const bool	ChannelRight::GetCanBanUser(void) const
{
	return this->_right[7];
}

void	ChannelRight::SetCanBanUser(const bool value)
{
	Configuration::GetConfiguration()->GetDatabase()->UpdateChannelRightCanBan(this->_id, value);
	this->_right[7] = value;
}
